package com.jianggujin.redis.panel.value;

import java.awt.BorderLayout;

import javax.swing.JPanel;

import com.jianggujin.redis.component.JEditorTable;
import com.jianggujin.redis.node.RedisKey;
import com.jianggujin.redis.panel.ValuePanel;

public class SetValuePanel extends JPanel implements ValuePanel {
    private JEditorTable valueTable;

    public SetValuePanel() {
        super(new BorderLayout());
        valueTable = new JEditorTable(new String[] { "Value", "Action" });
        valueTable.setRowSelectionAllowed(false);
        add(valueTable);
    }

    @Override
    public void showValue(RedisKey redisKey) {
        valueTable.removeAllRow();
        for (String item : redisKey.getClient().smembers(redisKey.getKey())) {
            valueTable.addRow(new Object[] { item });
        }
    }

}
